<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ProductGroupAjax
 *
 * @author tamph27989
 */
class ProductGroupAjax extends WebAjax{
    
    public function processRequest($action_type,  HttpRequest $request,HttpResponse $response) {
        switch ($action_type){
            case "getCategories":
                return $this->getCategories($request,$response);
            case "forwardProductGroupEdition":
                return $this->forwardProductGroupEdition($request,$response);
        }
        return '';
    }
    
    public function getCategories(HttpRequest $request,HttpResponse $response){
        $group_categories = new GroupCategoriesRM();
        $this->orm_builder->buildGroupCategories($group_categories); 
        $group_categories->findValidCategoriesByGroup($request->get("group_id"),$this->_USER_ID);
        $result_arr = array();
        while($group_categories->fetch()){
            $result_arr[] = array("CATEGORY_ID"=>$group_categories->CATEGORY_ID,"CATEGORY_NAME"=>$group_categories->CATEGORY_NAME,"TOTAL_PRODUCT"=>$group_categories->TOTAL_PRODUCT) ;
        }
        return $result_arr;
    }
    
    public function forwardProductGroupEdition(HttpRequest $request,HttpResponse $response){
        $result_arr = "";
       
        return $result_arr;
    }
}
